package com.company.arithmetic;

/**
 * Created by v on 17-2-22.
 */
public class Random {
    private static final int A=48271;
    private static final int M=2147483647;

    private int seed;

    public Random(){
        seed=(int) System.currentTimeMillis()%Integer.MAX_VALUE;
    }

    public Random(int seed){
        this.seed=seed;
    }

    public int nextInt(){
        return seed=(A*seed)%M;
    }

    public int nextInt(int bound){
        return (seed=(A*seed)%M)%bound;
    }
}
